/*****************************************************************************
State of Aadhaar Survey 2017-2018

Title: 7_User_awareness_pub.do
Author: IDinsight
Contact: stateofaadhaar@idinsight.org
Date: 29 August 2018
Data: "SOA2018_nonroster_cleaned_gen.dta"
User-written commands: estout (ssc install estout if not installed)
Description: 	This .do file conducts analysis for the User Awareness section 
				and produces output tables in "7_User_Awareness.rtf".

Contents:
	
	1. Analysis using non roster data
		- Survey set up
		- Tabulations / Proportions / Means
		- Regressions / Hypothesis tests
	
Missing data code:
	.r = refused
	.d = don't know	
*****************************************************************************/

	
* Setting up
	
	version 14
	capture log close
	clear all
	mac drop _all
	set more off
	
	* Please replace "..." below with the correct file path on your computer
	if "`c(os)'"=="MacOSX"{
		global dir "/Users/`c(username)'/.../SOA2018_data_release/"
		}
	else{
		global dir "C:/Users/`c(username)'/.../SOA2018_data_release/"
		}
		

/*****************************************************************************
1. Analysis using non roster data
*****************************************************************************/

	*** Survey set up

		cd "${dir}/Data_sets/"
		use "SOA2018_nonroster_cleaned_gen.dta", clear

		drop hh_id
		rename master_key hh_id 
		svyset district_id [pweight=weight_resp_adj] || AC_id || ps_id || hh_id || _n
		cd "${dir}/Output_tables/"
		

	***  Tabulations / Proportions / Means
		
		* Variable: govshare (Sharing of demographic information with a government agency)
			
			eststo clear
			eststo: estpost svy: tab govshare, percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (govshare ==.d | govshare ==.r)
			estadd scalar missing  = r(N)
			count if (govshare ==.e) 
			estadd scalar er  = r(N)
				forvalues i = 1/3 {
			display `i' 
			eststo: estpost svy: tab govshare if state == `i', percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (govshare ==.d | govshare ==.r) & state == `i'
			estadd scalar missing  = r(N)
			count if (govshare ==.e) & state == `i'
			estadd scalar er  = r(N)
				}
			
			esttab using "7_User_Awareness.rtf", ///
			compress ///
			collabels(none) ///
			eqlabels(none) ///
			label ///
			modelwidth(0) ///
			incelldelimiter(-) ///
			cells(b(fmt(1)) "cil & ciu") ///
			title ("Table 7.1 Percentage of respondents who believe it is important to know how a government agency would use personal information (e.g., name, age, address) shared by the respondent") ///	
			nostar ///
			nonumbers ///
			mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
			nogaps ///
			stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
			nonotes ///
			addnotes("Notes: 95% confidence intervals are under point estimates." ///
			"Respondents were asked: 'When you share your personal information (e.g., your name, age, address) with a government agency, how important is it to you to know how they will use it?' and were given the following options to choose from:'Important', 'Neutral' and 'Not Important'.") ///	
			replace 
			
			eststo clear
		
			
		* Variable: privshare (Sharing of demographic information with a private company)
		
			eststo: estpost svy: tab privshare, percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (privshare ==.d | privshare ==.r)
			estadd scalar missing  = r(N)
			count if (privshare ==.e) 
			estadd scalar er  = r(N)
				forvalues i = 1/3 {
			display `i' 
			eststo: estpost svy: tab privshare if state == `i', percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (privshare ==.d | privshare ==.r) & state == `i'
			estadd scalar missing  = r(N)
			count if (privshare ==.e) & state == `i'
			estadd scalar er  = r(N)
				}
			
			esttab using "7_User_Awareness.rtf", ///
			compress ///
			collabels(none) ///
			eqlabels(none) ///
			label ///
			modelwidth(0) ///
			incelldelimiter(-) ///
			cells(b(fmt(1)) "cil & ciu") ///
			title ("Table 7.2 Percentage of respondents who believe it is important to know how a private company would use personal information (e.g. name, age, address) shared by the respondent") ///	
			nostar ///
			nonumbers ///
			mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
			nogaps ///
			stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
			nonotes ///
			addnotes("Notes: 95% confidence intervals are under point estimates." ///
			"Respondents were asked: 'When you share your personal information (e.g., your name, age, address) with a private company, how important is it to you to know how they will use it?' and were given the following options to choose from:'Important', 'Neutral' and 'Not Important'.") ///	
			append 
			
			eststo clear
			
			
		* Variable: govbioshare (Sharing of biometric information with a government agency)
			
			eststo: estpost svy: tab govbioshare, percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (govbioshare ==.d | govbioshare ==.r)
			estadd scalar missing  = r(N)
			count if (govbioshare ==.e) 
			estadd scalar er  = r(N)
				forvalues i = 1/3 {
			display `i' 
			eststo: estpost svy: tab govbioshare if state == `i', percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (govbioshare ==.d | govbioshare ==.r) & state == `i'
			estadd scalar missing  = r(N)
			count if (govbioshare ==.e) & state == `i'
			estadd scalar er  = r(N)
				}
			
			esttab using "7_User_Awareness.rtf", ///
			compress ///
			collabels(none) ///
			eqlabels(none) ///
			label ///
			modelwidth(0) ///
			incelldelimiter(-) ///
			cells(b(fmt(1)) "cil & ciu") ///
			title ("Table 7.3 Percentage of respondents who believe it is important to know how a government agency would use biometric information shared by the respondent") ///	
			nostar ///
			nonumbers ///
			mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
			nogaps ///
			stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
			nonotes ///
			addnotes("Notes: 95% confidence intervals are under point estimates." ///
			"Respondents were asked: 'When you share your biometric information with a government agency, how important is it to you to know how they will use it?' and were given the following options to choose from:'Important', 'Neutral' and 'Not Important'.") ///	
			append 
			
			eststo clear
			
			
		* Variable privbioshare (Sharing of biometric information with a private company)
			
			eststo: estpost svy: tab privbioshare, percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (privbioshare ==.d | privbioshare ==.r)
			estadd scalar missing  = r(N)
			count if (privbioshare ==.e) 
			estadd scalar er  = r(N)
				forvalues i = 1/3 {
			display `i' 
			eststo: estpost svy: tab privbioshare if state == `i', percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (privbioshare ==.d | privbioshare ==.r) & state == `i'
			estadd scalar missing  = r(N)
			count if (privbioshare ==.e) & state == `i'
			estadd scalar er  = r(N)
				}
			
			esttab using "7_User_Awareness.rtf", ///
			compress ///
			collabels(none) ///
			eqlabels(none) ///
			label ///
			modelwidth(0) ///
			incelldelimiter(-) ///
			cells(b(fmt(1)) "cil & ciu") ///
			title ("Table 7.4 Percentage of respondents who believe it is important to know how a private company would use biometric information shared by the respondent") ///	
			nostar ///
			nonumbers ///
			mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
			nogaps ///
			stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
			nonotes ///
			addnotes("Notes: 95% confidence intervals are under point estimates." ///
			"Respondents were asked: 'When you share your biometric information with a private company, how important is it to you to know how they will use it?' and were given the following options to choose from:'Important', 'Neutral' and 'Not Important'.") ///	
			append 
			
			eststo clear
			
			
		* Variable: govadshare (Sharing of Aadhaar numbers with a government agency)
			
			eststo: estpost svy: tab govadshare, percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (govadshare ==.d | govadshare ==.r)
			estadd scalar missing  = r(N)
			count if (govadshare ==.e) 
			estadd scalar er  = r(N)
				forvalues i = 1/3 {
			display `i' 
			eststo: estpost svy: tab govadshare if state == `i', percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (govadshare ==.d | govadshare ==.r) & state == `i'
			estadd scalar missing  = r(N)
			count if (govadshare ==.e) & state == `i'
			estadd scalar er  = r(N)
				}
			
			esttab using "7_User_Awareness.rtf", ///
			compress ///
			collabels(none) ///
			eqlabels(none) ///
			label ///
			modelwidth(0) ///
			incelldelimiter(-) ///
			cells(b(fmt(1)) "cil & ciu") ///
			title ("Table 7.5 Percentage of respondents who believe it is important to know how a government agency would use their Aadhaar number (among those who have an Aadhaar)") ///	
			nostar ///
			nonumbers ///
			mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
			nogaps ///
			stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
			nonotes ///
			addnotes("Notes: 95% confidence intervals are under point estimates." ///
			"Respondents were asked: 'When you share your Aadhaar number with a government agency, how important is it to you to know how they will use it?' and were given the following options to choose from:'Important', 'Neutral' and 'Not Important'.") ///		
			append 
			
			eststo clear
			
		
		* Variable: privadshare (Sharing of Aadhaar numbers with a private company)
				
			eststo: estpost svy: tab privadshare, percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (privadshare ==.d | privadshare ==.r)
			estadd scalar missing  = r(N)
			count if (privadshare ==.e) 
			estadd scalar er  = r(N)
				forvalues i = 1/3 {
			display `i' 
			eststo: estpost svy: tab privadshare if state == `i', percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (privadshare ==.d | privadshare ==.r) & state == `i'
			estadd scalar missing  = r(N)
			count if (privadshare ==.e) & state == `i'
			estadd scalar er  = r(N)
				}
			
			esttab using "7_User_Awareness.rtf", ///
			compress ///
			collabels(none) ///
			eqlabels(none) ///
			label ///
			modelwidth(0) ///
			incelldelimiter(-) ///
			cells(b(fmt(1)) "cil & ciu") ///
			title ("Table 7.6 Percentage of respondents who believe it is important to know how a private company would use their Aadhaar number (among those who have an Aadhaar)") ///	
			nostar ///
			nonumbers ///
			mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
			nogaps ///
			stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
			nonotes ///
			addnotes("Notes: 95% confidence intervals are under point estimates." ///
			"Respondents were asked: 'When you share your Aadhaar number with a private company, how important is it to you to know how they will use it?' and were given the following options to choose from:'Important', 'Neutral' and 'Not Important'.") ///		
			append 
			
			eststo clear
		
		
		* Variable: govcompulsion
			
			eststo: estpost svy: tab govcompulsion, percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (govcompulsion ==.d | govcompulsion ==.r)
			estadd scalar missing  = r(N)
			count if (govcompulsion ==.e) 
			estadd scalar er  = r(N)
				forvalues i = 1/3 {
			display `i' 
			eststo: estpost svy: tab govcompulsion if state == `i', percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (govcompulsion ==.d | govcompulsion ==.r) & state == `i'
			estadd scalar missing  = r(N)
			count if (govcompulsion ==.e) & state == `i'
			estadd scalar er  = r(N)
				}
			
			esttab using "7_User_Awareness.rtf", ///
			compress ///
			collabels(none) ///
			eqlabels(none) ///
			label ///
			modelwidth(0) ///
			incelldelimiter(-) ///
			cells(b(fmt(1)) "cil & ciu") ///
			title ("Table 7.7 Percentage of respondents who approve of making Aadhaar mandatory for accessing government benefits ") ///	
			nostar ///
			nonumbers ///
			mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
			nogaps ///
			stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
			nonotes ///
			addnotes("Notes: 95% confidence intervals are under point estimates." ///
			"Respondents were asked: 'It is currently mandatory to have Aadhaar to access many government benefits, e.g. NREGA, PDS, pensions, mid-day meals. Do you approve or disapprove the government's decision to make Aadhaar mandatory to access government benefits?' The following options were read out loud: 'Approve', 'Neutral' and 'Disapprove'.") ///
			append 
			
			eststo clear
			
			
		* Variable: privcompulsion
			
			eststo: estpost svy: tab privcompulsion, percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (privcompulsion ==.d | privcompulsion ==.r)
			estadd scalar missing  = r(N)
			count if (privcompulsion ==.e) 
			estadd scalar er  = r(N)
				forvalues i = 1/3 {
			display `i' 
			eststo: estpost svy: tab privcompulsion if state == `i', percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (privcompulsion ==.d | privcompulsion ==.r) & state == `i'
			estadd scalar missing  = r(N)
			count if (privcompulsion ==.e) & state == `i'
			estadd scalar er  = r(N)
				}
			
			esttab using "7_User_Awareness.rtf", ///
			compress ///
			collabels(none) ///
			eqlabels(none) ///
			label ///
			modelwidth(0) ///
			incelldelimiter(-) ///
			cells(b(fmt(1)) "cil & ciu") ///
			title ("Table 7.8 Percentage of respondents who approve of making Aadhaar mandatory for accessing services of private companies") ///	
			nostar ///
			nonumbers ///
			mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
			nogaps ///
			stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
			nonotes ///
			addnotes("Notes: 95% confidence intervals are under point estimates." ///
			"Respondents were asked: 'Many companies are notifying their customers to link their Aadhaar card to their services, e.g. mobile phone companies, banks. Do you approve or disapprove the companies requiring you to link your Aadhaar to their services?' The following options were read out loud: 'Approve', 'Neutral' and 'Disapprove'.") ///
			append 
			
			eststo clear
		
		
		* Variable: lockaware
			
			eststo: estpost svy: tab lockaware, percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (lockaware ==.d | lockaware ==.r)
			estadd scalar missing  = r(N)
			count if (lockaware ==.e) 
			estadd scalar er  = r(N)
				forvalues i = 1/3 {
			display `i' 
			eststo: estpost svy: tab lockaware if state == `i', percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (lockaware ==.d | lockaware ==.r) & state == `i'
			estadd scalar missing  = r(N)
			count if (lockaware ==.e) & state == `i'
			estadd scalar er  = r(N)
				}
			
			esttab using "7_User_Awareness.rtf", ///
			compress ///
			collabels(none) ///
			eqlabels(none) ///
			label ///
			modelwidth(0) ///
			incelldelimiter(-) ///
			cells(b(fmt(1)) "cil & ciu") ///
			title ("Table 7.9 Percentage of respondents who are aware of their option to lock or unlock biometric authentication of their Aadhaar") ///	
			nostar ///
			nonumbers ///
			mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
			nogaps ///
			stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
			nonotes ///
			addnotes("Notes: 95% confidence intervals are under point estimates.") ///
			append 
			
			eststo clear
			
			
		* Variable: lock 
			
			eststo: estpost svy: tab lock, percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (lock ==.d | lock ==.r)
			estadd scalar missing  = r(N)
			count if (lock ==.e) 
			estadd scalar er  = r(N)
				forvalues i = 1/3 {
			display `i' 
			eststo: estpost svy: tab lock if state == `i', percent nototal ci
			estadd matrix cil = e(lb)
			estadd matrix ciu = e(ub)
			count if (lock ==.d | lock ==.r) & state == `i'
			estadd scalar missing  = r(N)
			count if (lock ==.e) & state == `i'
			estadd scalar er  = r(N)
				}
			
			esttab using "7_User_Awareness.rtf", ///
			compress ///
			collabels(none) ///
			eqlabels(none) ///
			label ///
			modelwidth(0) ///
			incelldelimiter(-) ///
			cells(b(fmt(1)) "cil & ciu") ///
			title ("Table 7.10 Percentage of respondents who have locked or unlocked their Aadhaar biometric authentication (among those who have an Aadhaar and are aware of this option)") ///	
			nostar ///
			nonumbers ///
			mtitles ("All three states" "Andhra Pradesh" "Rajasthan" "West Bengal") ///
			nogaps ///
			stats(N missing, fmt(0) label("Number of observations" "Number of missing observations (don't know / refused)")) ///
			nonotes ///
			addnotes("Notes: 95% confidence intervals are under point estimates.") ///
			append 
			
			eststo clear
